<template>
  <el-dialog v-bind="$attrs" width="800px">
    <super-form
      label-width="100px"
      size="middle"
      form-ref="modalForm"
      :form-data="formData"
      :render-form-item="renderFormItem"
      :form-buttons="formButtons"
    />
  </el-dialog>
</template>

<script>
import SuperForm from '@/components/SuperForm'
import { updateFormItem } from './config'
import { fetchDataSystemCreateAppSecret } from '@/api/indicatorlib/datasystem'
// import { fetchDepartDropdownList } from '../../../api/indicatorlib/department'

export default {
  name: 'AssessDepart',
  components: { SuperForm },
  props: {
    formData: {
      type: Object,
      default: () => ({})
    },
    handleSubmit: {
      type: Function,
      default: () => {}
    }
  },
  data() {
    return {
      appSecret: '',
      renderFormItem: updateFormItem(this.handleAutomaticGenerate),
      formButtons: {
        isDialog: true,
        submitName: '提交',
        resetName: '取消',
        submitCallback: values => this.handleSubmit(values),
        resetCallback: () => this.$emit('update:visible', false)
      }
    }
  },
  mounted() {
    // this.postDeptAllList()
    this.postAutomaticGenerate()
  },
  methods: {
    // postDeptAllList() {
    //   fetchDepartDropdownList({}).then(res => {
    //     this.$data.renderFormItem[0].slotAttrs.options = res.map(e => ({
    //       key: e.id,
    //       value: e.name
    //     }))
    //   })
    // }
    postAutomaticGenerate() {
      fetchDataSystemCreateAppSecret({}).then(res => {
        // this.appSecret = res.data
        this.$emit('updataAppSecret', res)
      })
    },
    handleAutomaticGenerate() {
      this.postAutomaticGenerate()
    }
  }
}
</script>

<style lang="scss" scoped></style>
